<template>
	<view class="cart-container">
		<!-- 顶部导航栏 -->
		<view class="navbar">
			<view class="navbar-title">购物车</view>
			<view class="navbar-actions">
				<view class="action-icon">
					<u-icon name="more-dot-fill" size="20" color="#999"></u-icon>
				</view>
				<view class="action-icon">
					<u-icon name="minus" size="20" color="#999"></u-icon>
				</view>
				<view class="action-icon">
					<u-icon name="checkmark-circle" size="20" color="#999"></u-icon>
				</view>
			</view>
		</view>

		<!-- 地址选择区域 -->
		<view class="address-section" @click="selectAddress">
			<view class="address-content">
				<view class="address-icon">
					<img style="width: 40rpx; height: 40rpx;" src="/static/profile/地址管理.png" alt="">
				</view>
				<view class="address-text">
					<text class="address-placeholder">请添加收货地址</text>
				</view>
				<view class="address-arrow">
					<u-icon name="arrow-right" size="16" color="#999"></u-icon>
				</view>
			</view>
		</view>

		<!-- 主要内容区域 -->
		<view class="main-content">
			<!-- 空状态插图 -->
			<view>
			<img src="/static/cart/空状态插图.png" alt="">
			</view>

			<!-- 空状态文字 -->
			<view class="empty-message">
				<text class="message-text">购物车是空的,快去挑选好货</text>
			</view>

			<!-- 去购物按钮 -->
			<view class="action-section">
				<u-button 
					type="primary" 
					text="去购物" 
					@click="goShopping"
					:custom-style="shoppingButtonStyle"
				></u-button>
			</view>
		</view>

		
		
	</view>
</template>

<script>
export default {
	data() {
		return {
			shoppingButtonStyle: {
				backgroundColor: '#ff4757',
				borderRadius: '12rpx',
				height: '80rpx',
				fontSize: '28rpx',
				fontWeight: '500',
				width: '200rpx'
			}
		}
	},
	methods: {
		// 选择地址
		selectAddress() {
			uni.showToast({
				title: '选择收货地址',
				icon: 'none'
			})
		},
		
		// 去购物
		goShopping() {
			uni.switchTab({
				url: '/pages/index/index'
			})
		},
		
		// 商品点击跳转
		goToProduct(product) {
			uni.navigateTo({
				url: `/pages/product/detail?id=${product.id}`
			});
		},
		// 结算跳转
		goToOrderList() {
			uni.navigateTo({
				url: '/pages/order/order-list'
			});
		},
		// tabbar 跳转
		switchTab(tab) {
			switch(tab) {
				case 'home':
					uni.switchTab({ url: '/pages/index/index' });
					break;
				case 'category':
					uni.switchTab({ url: '/pages/category/category' });
					break;
				case 'cart':
					// 当前页
					break;
				case 'person':
					uni.switchTab({ url: '/pages/person/person' });
					break;
			}
		}
	}
}
</script>

<style lang="scss" scoped>
.cart-container {
	min-height: 100vh;
	background-color: #f8f9fa;
	position: relative;
}

.navbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20rpx 30rpx;
	background-color: #fff;
	border-bottom: 1rpx solid #f0f0f0;
	
	.navbar-title {
		text-align: center;
		margin: 40rpx 100rpx 0 300rpx;
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}
	
	.navbar-actions {
		display: flex;
		gap: 20rpx;
		
		.action-icon {
			width: 40rpx;
			height: 40rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
}

.address-section {
	background-color: #fff;
	margin-bottom: 20rpx;
	
	.address-content {
		display: flex;
		align-items: center;
		padding: 30rpx;
		
		.address-icon {
			margin-right: 20rpx;
		}
		
		.address-text {
			flex: 1;
			
			.address-placeholder {
				font-size: 28rpx;
				color: #666;
			}
		}
		
		.address-arrow {
			margin-left: 20rpx;
		}
	}
}

.main-content {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 60rpx 40rpx;
	background-color: #f5f7fa;
}

.empty-illustration {
	margin-bottom: 40rpx;
	
	.illustration-container {
		position: relative;
		width: 400rpx;
		height: 300rpx;
		
		.cart-scene {
			position: relative;
			width: 100%;
			height: 100%;
			
			.cloud-bg {
				position: absolute;
				top: 20rpx;
				right: 40rpx;
				width: 120rpx;
				height: 60rpx;
				background-color: #f0f0f0;
				border-radius: 60rpx;
				opacity: 0.6;
			}
			
			.person {
				position: absolute;
				left: 60rpx;
				bottom: 80rpx;
				
				.person-head {
					width: 40rpx;
					height: 40rpx;
					background-color: #333;
					border-radius: 50%;
					margin-bottom: 10rpx;
				}
				
				.person-body {
					width: 60rpx;
					height: 80rpx;
					background-color: #ffb6c1;
					border-radius: 30rpx 30rpx 20rpx 20rpx;
				}
				
				.person-arms {
					position: absolute;
					top: 20rpx;
					left: -10rpx;
					width: 80rpx;
					height: 20rpx;
					background-color: #ffb6c1;
					border-radius: 10rpx;
				}
			}
			
			.shopping-cart {
				position: absolute;
				left: 120rpx;
				bottom: 60rpx;
				
				.cart-body {
					width: 120rpx;
					height: 80rpx;
					background-color: #ccc;
					border-radius: 10rpx;
					position: relative;
					
					&::before {
						content: '';
						position: absolute;
						top: 10rpx;
						left: 10rpx;
						right: 10rpx;
						bottom: 10rpx;
						background-color: #f8f9fa;
						border-radius: 5rpx;
					}
				}
				
				.cart-handle {
					position: absolute;
					top: -20rpx;
					left: 20rpx;
					width: 80rpx;
					height: 20rpx;
					background-color: #999;
					border-radius: 10rpx;
				}
				
				.cart-wheels {
					position: absolute;
					bottom: -10rpx;
					left: 0;
					right: 0;
					display: flex;
					justify-content: space-between;
					padding: 0 10rpx;
					
					.wheel {
						width: 20rpx;
						height: 20rpx;
						background-color: #666;
						border-radius: 50%;
					}
				}
			}
			
			.plant {
				position: absolute;
				right: 20rpx;
				bottom: 60rpx;
				
				.plant-pot {
					width: 30rpx;
					height: 25rpx;
					background-color: #8b4513;
					border-radius: 15rpx 15rpx 5rpx 5rpx;
				}
				
				.plant-leaves {
					position: absolute;
					top: -15rpx;
					left: 5rpx;
					width: 20rpx;
					height: 20rpx;
					background-color: #90ee90;
					border-radius: 50%;
				}
			}
		}
	}
}

.empty-message {
	margin-bottom: 60rpx;
	
	.message-text {
		font-size: 28rpx;
		color: #999;
	}
}

.action-section {
	margin-bottom: 120rpx;
}

</style> 